<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input class="ipt1" type="text" />+<input class="ipt2" type="text" />
    <button>=</button>
    <input class="ipt3" type="text" />
  </body>
</html>
<script>
  var oIpt1 = document.querySelector(".ipt1"); //获取类名为ipt1的输入框
  var oIpt2 = document.querySelector(".ipt2"); //获取类名为ipt2的输入框
  var oIpt3 = document.querySelector(".ipt3"); //获取类名为ipt3的输入框
  var oBtn = document.querySelector("button"); //获取button标签按钮
  oBtn.onclick = function () {
    //给按钮添加点击事件
    oIpt3.value = oIpt1.value * 1 + oIpt2.value * 1; //ipt3输入框的值等于获取到的ipt1的值加上获取到的ipt2的值，顺便将字符串类型转为数字类型
  };
</script>
